package cn.yangliu.entity;

import cn.yangliu.base.JpaBaseBean;
import cn.yangliu.comm.CommConst;
import cn.yangliu.comm.shiro.Account;
import com.alibaba.fastjson.annotation.JSONField;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;

/**
 * 作者 杨柳
 * 创建时间 2017-08-26 23:43
 */

@Entity
@Table(name = "jpa_user")
public class JpaUser extends JpaBaseBean implements Account<JpaUser>{

    @Length(max = 20,min = 6,message = "用户名长度6-20")
    private String username;

    private String password;
    @DateTimeFormat(pattern = CommConst.DATE_PATTERN)
    private LocalDate birth;

    @Min(value = 18, message = "年龄必须大于18")
    @Max(value = 100,message = "年龄必须小于100")
    private Integer age;

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public LocalDate getBirth() {
        return birth;
    }

    public void setBirth(LocalDate birth) {
        this.birth = birth;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    @JSONField(serialize = false)
    public Serializable getSerializableId() {
        return getId();
    }
}
